#include<iostream>
#include<unordered_map>
#include<vector>
#include<unordered_set>
#include<algorithm>
#include<map>
using namespace std;


void solve()
{
	vector<int> arr;
	int n; cin >> n;
	for (int i = 0; i < n; i++)
	{
		int temp; cin >> temp;
		arr.push_back(temp);
	}
	for (int i = 0; i < arr.size() - 1; i++)
	{
		int temp = abs(arr[i] - arr[i + 1]);
		if (temp != 5 && temp != 7)
		{
			cout << "NO" << endl; return;
		}
	}
	cout << "YES" << endl;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int t; cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}
